package com.example.validdemo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author Bx_Hu
 */
@SpringBootApplication
@Slf4j
public class ValidDemoApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(ValidDemoApplication.class, args);
        ConfigurableEnvironment environment = run.getEnvironment();
        String port = environment.getProperty("server.port");
        String path = environment.getProperty("server.servlet.context-path");
        InetAddress localHost = null;
        try {
            localHost = Inet4Address.getLocalHost();
        } catch (UnknownHostException e) {
            log.error(e.getMessage(), e);
        }
        log.info("============================   项目启动成功  ==============================");
        log.info("本地地址: http://localhost:{}{}", port, path);
        log.info("文档地址: http://localhost:{}{}doc.html", port, path);
        log.info("IP 地址 : http://{}:{}{}", localHost == null ? "localhost" : localHost.getHostAddress(), port, path);
        log.info("==========================================================================");
    }

}
